<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>发布信息列表</title>

    <meta name="keywords" content="">
    <meta name="description" content="">

    <!--[if lt IE 8]>
    <script>
        alert('H+已不支持IE6-8，请使用谷歌、火狐等浏览器\n或360、QQ等国产浏览器的极速模式浏览本页面！');
    </script>
    <![endif]-->

    <link href="/static/admin/public/css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
    <link href="/static/admin/public/css/font-awesome.min.css?v=4.3.0" rel="stylesheet">
    <link href="/static/admin/public/css/animate.min.css" rel="stylesheet">
    <link href="/static/toastr/toastr.min.css" rel="stylesheet"></link>
    <link href="/static/admin/public/css/style.min.css?v=3.2.0" rel="stylesheet">
    <link href="/static/admin/plugins/jsTree/css/style.min.css" rel="stylesheet">
</head>

<body class="fixed-sidebar full-height-layout gray-bg">
<div class="wrapper wrapper-content animated fadeInRight" id="contentList">
    <div class="ibox float-e-margins" >

        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5 class="pull-left">货源招标</h5>
            </div>
            <div class="ibox-content">
                <div class="row form-horizontal m-t">
                    <div class="col-sm-3 ">
                        <div class="form-group"><label class="col-sm-3 control-label">标题：</label>
                            <div class="col-sm-9"><input v-model="title"  name="name"  type="text" class="form-control"></div>
                        </div>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group"><label class="col-sm-3 control-label">开始时间：</label>
                            <div class="col-sm-9"><input readonly id="company_time" v-model="start_time"  name="name"  type="text" class="form-control"></div>
                        </div>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group"><label class="col-sm-3 control-label">结束时间：</label>
                            <div class="col-sm-9"><input readonly id="company_time2" v-model="end_time" name="name"  type="text" class="form-control"></div>
                        </div>
                    </div>
                    <div class="col-sm-3 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">状态：</label>
                            <div class="col-sm-6">
                                <select v-model="status"  name="name"  type="text" class="form-control">
                                    <option value="0">全部</option>
                                    <option value="1">待审核</option>
                                    <option value="2">已发布</option>
                                    <option value="3">未通过</option>
                                    <option value="4">已截止</option>
                                </select>
                            </div>
                            <div class="col-sm-3">
                                <div class="form-group">
                                    <button type="button" class="btn btn-primary" @click="changeWhereGetList()">查询</button>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
                <table class="table">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>所述分类</th>
                        <th>标题</th>
                        <th>公司名称</th>
                        <th>联系人</th>
                        <th>手机</th>
                        <th>服务类型</th>
                        <th>货物类别</th>
                        <th>地区</th>
                        <th>金额(万元/年)</th>
                        <th>发布时间</th>
                        <th>更新时间</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr v-for="(item,index) in list">
                        <td>{{(((current_page-1)*num)+index)+1}}</td>

                        <td>{{item_category_status[item.item_category-1]}}</td>
                        <td>{{item.title}}</td>
                        <td>{{item.member_name}}</td>
                        <td>{{item.member_contacts}}</td>
                        <td>{{item.member_mobile}}</td>
                        <td>{{item.service_name}}</td>
                        <td>{{item.trade_name}}</td>
                        <td>{{item.city}}</td>
                        <td>{{item.budget}}</td>
                        <td>{{item.create_time}}</td>
                        <td>{{item.update_time}}</td>
                        <td>
                            <div role="group" aria-label="..." class="btn-group">
                                <!--                                "[{'btn-success':item.status==1},{'btn-danger':item.status==0}]"-->
                                <button v-if="item.status == 1" type="button"
                                        class="btn btn-xs btn-warning">
                                        待审核
                                </button>
                                <button v-if="item.status == 2" type="button"
                                        class="btn btn-xs btn-primary">
                                    已发布
                                </button>
                                <button v-if="item.status == 3" type="button"
                                        class="btn btn-xs btn-danger">
                                    未通过
                                </button>
                                <button v-if="item.status == 4" type="button"
                                        class="btn btn-xs btn-default">
                                    已截止
                                </button>
                            </div>
                        </td>

                        <td>
                            <div role="group" aria-label="..." class="btn-group">
                                <a v-bind:href="'/admin/freight/apply/id/'+item.id" type="button" class="btn btn-primary btn-xs">查看申请</a>
                                <a v-bind:href="'/admin/freight/detail/id/'+item.id" type="button" class="btn btn-success btn-xs">查看详情</a>
                                <button @click="remove(item.id,index)" type="button" class="btn btn-danger btn-xs">删除</button>
                            </div>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div class="ibox-content text-center">
                <div class="btn-group">
                    <button type="button" class="btn btn-white" @click="pageNextList(-1)"><i class="fa fa-chevron-left"></i>
                    </button>

                    <button class="btn" v-bind:class="pageInfo.current_page==item?'btn-primary':'btn-white'" v-for="item in pageInfo.total" @click="changePage(item)">{{item}}</button>
                    <button type="button" class="btn btn-white">
                        <i class="fa fa-chevron-right" @click="pageNextList(1)">
                        </i>
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="/static/admin/public/js/jquery-2.1.1.min.js"></script>
<script src="/static/admin/public/js/bootstrap.min.js?v=3.4.0"></script>
<script src="/static/admin/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/static/admin/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/static/admin/plugins/layer/layer.min.js"></script>
<script type="text/javascript" src="/static/vue/vue.js"></script>

<!-- 自定义js -->
<script type="text/javascript" src="/static/util/axios.min.js"></script>
<script type="text/javascript" src="/static/admin/api/require.js"></script>
<script type="text/javascript" src="/static/admin/api/publicAjax.js"></script>

<!-- 第三方插件 -->
<script src="/static/toastr/toastr.min.js"></script>
<script src="/static/toastr/customToastr.js"></script>
<script src="/static/admin/plugins/jsTree/js/jstree.min.js"></script>
<!--时间组件-->
<script src="/static/util/laydate/laydate.js"></script>
<script>
    var vmAddChannel = new Vue({
        el:"#contentList",
        data:{
            "item_status":["待审核",'已发布','未通过','已截止'],
            'item_category_status':['招标公告','实时货源'],
            "list":[],
            'current_page':1,
            'num':15,
            "pageInfo":{},
            'start_time':'',
            'end_time':'',
            'title':'',
            'status':0
        },
        methods:{
            pageNextList:function (num) {
                var el = this;
                var num = num;
                var pageNum = el.current_page+num
                if( pageNum < 1){
                    $.customToastr("error","已经是第一页啦");
                    return;
                }
                if(pageNum > el.pageInfo.total){
                    $.customToastr("error","已经是最后一页啦");
                    return;
                }
                el.current_page = pageNum

                el.getList();
            },
            changePage:function(num){
                var el = this
                el.current_page = num
                el.getList();
            },
            //条件更改无法从第一页查询，跳转方法
            changeWhereGetList:function(){
                var el = this
                el.current_page = 1
                el.getList()
            },
            getList:function () {
                let el = this
                var paging = {
                    'current_page':el.current_page,
                    'num':el.num
                }
                let postData = {
                   'paging':paging,
                    'title':'',
                    'end_time':'',
                    'start_time':'',
                    'status':el.status
                }
                if(el.title!=''){
                    postData.title = el.title
                }
                if(el.end_time!=''&&el.start_time!=''){
                    postData.end_time = el.end_time
                    postData.start_time = el.start_time
                }
                AjaxPost(postData,'/admin/freight/getList').then((response)=>{
                    var list = response.result.list
                    console.log(response.result.list)
                    if(list){
                        el.list = list
                        el.pageInfo = response.result.pageInfo
                    }else {
                        el.list = []
                        el.pageInfo = {}
                    }

                })
            },
            remove:function (id,subNum) {
                var el = this;
                var postData = {
                    "id":id
                }
                layer.confirm('确定要删除吗？', {
                    btn: ['确定','取消'] //按钮
                }, function(index){
                    layer.close(index)
                    AjaxPost(postData,'/admin/freight/removeFreight').then((response)=>{
                        $.customToastr('success',response.message)
                        el.list.splice(subNum,1)
                    })
                });

            },
        },
        mounted(){
            var el = this
            this.getList();
            laydate.render({
                elem: '#company_time', //指定元素
                done: function (value,date,endDate) {
                    el.start_time =value
                }
            });
            laydate.render({
                elem: '#company_time2', //指定元素
                done: function (value,date,endDate) {
                    el.end_time =value
                }
            });
        }

    })
</script>

</body>
</html>